<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
      <title>GTL - Graph Template Library: ne_map.h Source File</title>
      <link href="doxygen.css" rel="stylesheet" type="text/css">
  </head>
  <body>
    <p class="links">  
      <a href="../index.html">Home</a> |
      Documentation |
      <a href="../register.html">Download</a> |
      <a href="../platforms.html">Platforms</a> |
      <a href="../refer.html">Projects</a> |      
      <a href="../lists.html">Mailing Lists</a> |
      <a href="../history.html">Version History</a>
    </p>

<!-- Generated by Doxygen 1.5.3 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="classes.html"><span>Classes</span></a></li>
    <li class="current"><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  </ul>
</div>
<h1>ne_map.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//==========================================================================</span>
<a name="l00002"></a>00002 <span class="comment">//</span>
<a name="l00003"></a>00003 <span class="comment">//   ne_map.h - common implementation of node_map and edge_map</span>
<a name="l00004"></a>00004 <span class="comment">//</span>
<a name="l00005"></a>00005 <span class="comment">//==========================================================================</span>
<a name="l00006"></a>00006 <span class="comment">// $Id: ne_map.h,v 1.20 2005/06/14 12:22:12 raitner Exp $</span>
<a name="l00007"></a>00007 
<a name="l00008"></a>00008 <span class="preprocessor">#ifndef GTL_NE_MAP_H</span>
<a name="l00009"></a>00009 <span class="preprocessor"></span><span class="preprocessor">#define GTL_NE_MAP_H</span>
<a name="l00010"></a>00010 <span class="preprocessor"></span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &lt;GTL/GTL.h&gt;</span>
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;cassert&gt;</span>
<a name="l00015"></a>00015 
<a name="l00016"></a>00016 <span class="comment">//--------------------------------------------------------------------------</span>
<a name="l00017"></a>00017 <span class="comment">//   Class declaration</span>
<a name="l00018"></a>00018 <span class="comment">//--------------------------------------------------------------------------</span>
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 __GTL_BEGIN_NAMESPACE
<a name="l00021"></a>00021 
<a name="l00029"></a>00029 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Key, <span class="keyword">class</span> Value, <span class="keyword">class</span> Graph, <span class="keyword">class</span> Alloc = allocator&lt;Value&gt; &gt; 
<a name="l00030"></a><a class="code" href="a00019.html">00030</a> <span class="keyword">class </span><a class="code" href="a00019.html" title="Baseclass for node_map and edge_map.">ne_map</a>
<a name="l00031"></a>00031 {
<a name="l00032"></a>00032 <span class="keyword">protected</span>:
<a name="l00033"></a>00033     
<a name="l00034"></a>00034     <span class="comment">//================================================== Constructors</span>
<a name="l00035"></a>00035 
<a name="l00040"></a>00040     <a class="code" href="a00019.html#cbe94c2209408e8af27fb9580251f360">ne_map</a>();
<a name="l00041"></a>00041 
<a name="l00053"></a>00053     <span class="keyword">explicit</span> <a class="code" href="a00019.html#cbe94c2209408e8af27fb9580251f360">ne_map</a>(<span class="keyword">const</span> Graph &amp;g, Value def=Value());
<a name="l00054"></a>00054 
<a name="l00055"></a>00055     <span class="comment">//================================================== Operations</span>
<a name="l00056"></a>00056     
<a name="l00057"></a>00057 <span class="keyword">public</span>:
<a name="l00058"></a>00058 
<a name="l00066"></a>00066     <span class="keywordtype">void</span> <a class="code" href="a00019.html#4ef2ab4aebcb57a7a101975bf6a88e24">init</a>(<span class="keyword">const</span> Graph &amp;, Value def=Value());
<a name="l00067"></a>00067 
<a name="l00071"></a>00071 <span class="preprocessor">#if defined(__GTL_MSVCC) &amp;&amp; _MSC_VER &lt; 1310</span>
<a name="l00072"></a>00072 <span class="preprocessor"></span>    <span class="keyword">typedef</span> Value&amp; value_reference;
<a name="l00073"></a>00073 <span class="preprocessor">#else</span>
<a name="l00074"></a>00074 <span class="preprocessor"></span>    <span class="keyword">typedef</span> <span class="keyword">typename</span> vector&lt;Value, Alloc&gt;::reference value_reference;
<a name="l00075"></a>00075 <span class="preprocessor">#endif</span>
<a name="l00076"></a>00076 <span class="preprocessor"></span>
<a name="l00080"></a>00080 <span class="preprocessor">#if defined(__GTL_MSVCC) &amp;&amp; _MSC_VER &lt; 1310</span>
<a name="l00081"></a>00081 <span class="preprocessor"></span>    <span class="keyword">typedef</span> <span class="keyword">const</span> Value&amp; const_value_reference;
<a name="l00082"></a>00082 <span class="preprocessor">#else</span>
<a name="l00083"></a>00083 <span class="preprocessor"></span>    <span class="keyword">typedef</span> <span class="keyword">typename</span> vector&lt;Value, Alloc&gt;::const_reference const_value_reference;
<a name="l00084"></a>00084 <span class="preprocessor">#endif</span>
<a name="l00085"></a>00085 <span class="preprocessor"></span>    
<a name="l00103"></a>00103     value_reference <a class="code" href="a00019.html#4bcfa7ec2dcbfaa42fab93dfa81e8ab0">operator[]</a>(Key key);
<a name="l00104"></a>00104 
<a name="l00120"></a>00120     const_value_reference <a class="code" href="a00019.html#4bcfa7ec2dcbfaa42fab93dfa81e8ab0">operator[]</a>(Key key) <span class="keyword">const</span>;
<a name="l00121"></a>00121 
<a name="l00125"></a>00125     <span class="keywordtype">void</span> <a class="code" href="a00019.html#ebe555c23769c6dcc869b5ac7fae6a9c">clear</a> ();
<a name="l00126"></a>00126 
<a name="l00127"></a>00127     <span class="comment">//================================================== Implementation</span>
<a name="l00128"></a>00128     
<a name="l00129"></a>00129 <span class="keyword">private</span>:
<a name="l00130"></a>00130     vector&lt;Value, Alloc&gt; data;
<a name="l00131"></a>00131 };
<a name="l00132"></a>00132 
<a name="l00133"></a>00133 <span class="comment">// Implementation Begin</span>
<a name="l00134"></a>00134 
<a name="l00135"></a>00135 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Key, <span class="keyword">class</span> Value, <span class="keyword">class</span> Graph, <span class="keyword">class</span> Alloc&gt;
<a name="l00136"></a><a class="code" href="a00019.html#cbe94c2209408e8af27fb9580251f360">00136</a>   <a class="code" href="a00019.html#cbe94c2209408e8af27fb9580251f360">ne_map&lt;Key,Value,Graph,Alloc&gt;::ne_map</a>()
<a name="l00137"></a>00137 {
<a name="l00138"></a>00138 }
<a name="l00139"></a>00139 
<a name="l00140"></a>00140 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Key, <span class="keyword">class</span> Value, <span class="keyword">class</span> Graph, <span class="keyword">class</span> Alloc&gt;
<a name="l00141"></a><a class="code" href="a00019.html#769ee373d4cd8d3ef2c1577372da149c">00141</a> <a class="code" href="a00019.html#cbe94c2209408e8af27fb9580251f360">ne_map&lt;Key,Value,Graph,Alloc&gt;::ne_map</a>(<span class="keyword">const</span> Graph &amp;g, Value t2) :
<a name="l00142"></a>00142     data(g.number_of_ids(Key()), t2)
<a name="l00143"></a>00143 {
<a name="l00144"></a>00144 }
<a name="l00145"></a>00145 
<a name="l00146"></a>00146 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Key, <span class="keyword">class</span> Value, <span class="keyword">class</span> Graph, <span class="keyword">class</span> Alloc&gt;
<a name="l00147"></a><a class="code" href="a00019.html#4ef2ab4aebcb57a7a101975bf6a88e24">00147</a> <span class="keywordtype">void</span> <a class="code" href="a00019.html#4ef2ab4aebcb57a7a101975bf6a88e24">ne_map&lt;Key,Value,Graph,Alloc&gt;::init</a>(<span class="keyword">const</span> Graph &amp;g, Value t2)
<a name="l00148"></a>00148 {
<a name="l00149"></a>00149     <span class="keywordtype">int</span> n = g.number_of_ids(Key());
<a name="l00150"></a>00150     data.resize(n);
<a name="l00151"></a>00151     fill_n(data.begin(), n, t2);
<a name="l00152"></a>00152 }
<a name="l00153"></a>00153 
<a name="l00154"></a>00154 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Key, <span class="keyword">class</span> Value, <span class="keyword">class</span> Graph, <span class="keyword">class</span> Alloc&gt;
<a name="l00155"></a><a class="code" href="a00019.html#4bcfa7ec2dcbfaa42fab93dfa81e8ab0">00155</a> <span class="keyword">typename</span> <a class="code" href="a00019.html" title="Baseclass for node_map and edge_map.">ne_map&lt;Key,Value,Graph,Alloc&gt;::value_reference</a> <a class="code" href="a00019.html#4bcfa7ec2dcbfaa42fab93dfa81e8ab0">ne_map&lt;Key,Value,Graph,Alloc&gt;::operator[]</a>(Key t1)
<a name="l00156"></a>00156 {
<a name="l00157"></a>00157     <span class="keywordflow">if</span>(t1.id() &gt;= (signed)data.size())
<a name="l00158"></a>00158     {
<a name="l00159"></a>00159         <span class="keywordflow">if</span> (t1.id() &gt;= (signed)data.capacity()) {
<a name="l00160"></a>00160             data.reserve((6 * t1.id()) / 5 + 1);
<a name="l00161"></a>00161         }
<a name="l00162"></a>00162 
<a name="l00163"></a>00163         data.insert(data.end(), t1.id()+1-data.size(), Value());
<a name="l00164"></a>00164     }
<a name="l00165"></a>00165     <span class="keywordflow">return</span> data.operator[](t1.id());
<a name="l00166"></a>00166 }
<a name="l00167"></a>00167 
<a name="l00168"></a>00168 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Key, <span class="keyword">class</span> Value, <span class="keyword">class</span> Graph, <span class="keyword">class</span> Alloc&gt;
<a name="l00169"></a><a class="code" href="a00019.html#1b6fd0142573c9140de20dcc43c5aa55">00169</a> <span class="keyword">typename</span> <a class="code" href="a00019.html" title="Baseclass for node_map and edge_map.">ne_map&lt;Key,Value,Graph,Alloc&gt;::const_value_reference</a> <a class="code" href="a00019.html#4bcfa7ec2dcbfaa42fab93dfa81e8ab0">ne_map&lt;Key,Value,Graph,Alloc&gt;::operator[]</a>(Key t1)<span class="keyword"> const</span>
<a name="l00170"></a>00170 <span class="keyword"></span>{
<a name="l00171"></a>00171     assert(t1.id() &lt; (signed)data.size());
<a name="l00172"></a>00172     <span class="keywordflow">return</span> data.operator[](t1.id());
<a name="l00173"></a>00173 }
<a name="l00174"></a>00174 
<a name="l00175"></a>00175 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Key, <span class="keyword">class</span> Value, <span class="keyword">class</span> Graph, <span class="keyword">class</span> Alloc&gt;
<a name="l00176"></a><a class="code" href="a00019.html#ebe555c23769c6dcc869b5ac7fae6a9c">00176</a> <span class="keywordtype">void</span> <a class="code" href="a00019.html#ebe555c23769c6dcc869b5ac7fae6a9c">ne_map&lt;Key,Value,Graph,Alloc&gt;::clear</a> ()
<a name="l00177"></a>00177 {
<a name="l00178"></a>00178     data.clear();
<a name="l00179"></a>00179 }
<a name="l00180"></a>00180 
<a name="l00181"></a>00181 <span class="comment">// Implementation End</span>
<a name="l00182"></a>00182 
<a name="l00183"></a>00183 __GTL_END_NAMESPACE
<a name="l00184"></a>00184 
<a name="l00185"></a>00185 <span class="preprocessor">#endif // GTL_NE_MAP_H</span>
<a name="l00186"></a>00186 <span class="preprocessor"></span>
<a name="l00187"></a>00187 <span class="comment">//--------------------------------------------------------------------------</span>
<a name="l00188"></a>00188 <span class="comment">//   end of file</span>
<a name="l00189"></a>00189 <span class="comment">//--------------------------------------------------------------------------</span>
</pre></div>    <p class="links">
      <a href="http://www.uni-passau.de/">University of Passau</a>
      &nbsp;-&nbsp;
      <a href="http://www.fmi.uni-passau.de/">FMI</a>
      &nbsp;-&nbsp;
      <a href="http://www.fmi.uni-passau.de/fmi/lehrstuehle/brandenburg/">Theoretical
	Computer Science</a>
    </p>
  <div class="copyright">
      Design &copy; 2002, 2003 <a href="mailto:raitner@fmi.uni-passau.de">Marcus Raitner</a>,  University of Passau 
  </div>
</body>
</html>
